package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.project.bean.BuyCarBean;
import com.project.mapper.IBuyCarMapper;
import com.project.service.IBuyCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 采购车业务接口
 */
@Service
@Transactional
public class BuyCarServiceImpl implements IBuyCarService {
    @Autowired
    private IBuyCarMapper buyCarMapper;
    @Override
    public List<BuyCarBean> findByUserId(Integer userId) {
        return buyCarMapper.findByUserId(userId);
    }

    @Override
    public void del(Integer id) {
        buyCarMapper.deleteById(id);
    }

    @Override
    public void update(Integer id, Integer price, Integer num) {
        BuyCarBean buyCarBean = buyCarMapper.selectById(id);
        buyCarBean.setPrice(price);
        buyCarBean.setNum(num);
        buyCarMapper.updateById(buyCarBean);
    }
}
